/**
 * Copyright 2007 MartiniMix.net
 */
package net.martinimix.logging;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.bluemartini.dna.BMException;
import com.bluemartini.dna.BMLog;
import com.bluemartini.dna.Callback;
import com.bluemartini.dna.DNAList;

/**
 * Provides a startup call back to Intialize this Blue Martini 
 * Commons Logging implementation.
 * 
 * @author Scott Rossillo
 *
 */
public class LogStartupCallback implements Callback {

	private static final Log log = LogFactory.getLog(LogStartupCallback.class);
	private static boolean initialized = false;

	/**
	 * Returns true if the log system is initialized.
	 * 
	 * @return <code>true</code> if the log system is initialized;
	 * <code>false</code> otherwise
	 */
	public static boolean isInitialiazed() {
		return initialized;
	}

	public DNAList execute(DNAList in) throws BMException {
		
		try {
			BMLog.init();
		} catch (BMException e) {
			throw new BMException("Failed to initialize BMLog: " + e.getMessage());
		}
		
		log.info("Done initializing log system.");
		initialized = true;
		
		return null;
	}

}
